public class ClientClass {
    public static void main(String[] args){
        Factory factory = new Factory();

        // 原始用法
        Fruit apple = factory.CreateFruit("A");
        apple.eat();  // 输出：eat Apple

        // 装饰器用法
        Fruit washedApple = new WashedFruit(factory.CreateFruit("A"));
        washedApple.eat();
        /* 输出：
           Washing Apple
           eat Apple
        */

        // 多重装饰
        Fruit peeledAndWashedBanana = new PeeledFruit(
                new WashedFruit(
                        factory.CreateFruit("B")
                )
        );
        peeledAndWashedBanana.eat();
        /* 输出：
           Peeling WashedFruit
           Washing Banana
           eat Banana
        */
    }
}